/*
 * Project Name demo
 * File Name MessageTyoeEnum
 * Package Name com.huxiaosu.demo.socketio.util
 * Create Time 2023/1/31
 * Create by name：liujie
 */
package com.huxiaosu.demo.socketio.util;


import java.awt.*;

/**
 * Description
 *
 * @ClassName: MessageTypeEnum
 * @author: liujie
 * @date: 2023/1/31 15:15
 */
public enum MessageTypeEnum {
    /**产品咨询消息*/
    PRODUCT(1,"产品咨询消息"),
    DEFAULT(2,"default"),
    ;
    private int type;
    private String name;

    MessageTypeEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }
    public static MessageTypeEnum getByType(final int type){
        for(MessageTypeEnum item:values()){
            if(item.getType() == type){
                return item;
            }
        }
        return DEFAULT;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public interface ChildMessageType{
        int getType();
        String getName();
        enum Product implements ChildMessageType{

            /**
             * 图片
             */
            PIC(1, "pic"),
            /**
             * 文本
             */
            TEXT(2, "text"),
            /**
             * 文件
             */
            FILE(3, "file"),
            /**
             * 表情
             */
            EMOJI(4, "emoji"),
            ;
            private int type;
            private String name;

            Product(int type, String name) {
                this.type = type;
                this.name = name;
            }

            public static MessageTypeEnum getParentType(){
                return MessageTypeEnum.PRODUCT;
            }
            public static ChildMessageType getByType(final int type){
                for(ChildMessageType item:values()){
                    if(item.getType() == type){
                        return item;
                    }
                }
                return TEXT;
            }
            @Override
            public int getType() {
                return this.type;
            }

            @Override
            public String getName() {
                return this.name;
            }
        }
    }
}